/*    */ package com.newcrm.thread;
/*    */ 
/*    */ import com.newcrm.db.ImportantDateManager;
/*    */ import com.newcrm.db.TaskManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.util.Util;
/*    */ import java.io.Serializable;
/*    */ import java.sql.SQLException;
/*    */ import java.util.Calendar;
/*    */ import java.util.Date;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.TimerTask;
/*    */ 
/*    */ public class ImportantDateThread extends TimerTask
/*    */   implements Serializable
/*    */ {
/*    */   private static final long serialVersionUID = 1313846235197414962L;
/*    */ 
/*    */   public void run()
/*    */   {
/* 33 */     Calendar cal = Calendar.getInstance();
/*    */ 
/* 35 */     cal.add(5, 7);
/* 36 */     int year = cal.get(1);
/* 37 */     int month = cal.get(2) + 1;
/* 38 */     int day = cal.get(5);
/* 39 */     cal.set(year, month - 1, day, 0, 0, 0);
/*    */ 
/* 41 */     ImportantDateManager manager = new ImportantDateManager();
/*    */     try {
/* 43 */       List result = manager.getLastImportDates(year,
/* 44 */         month, day);
/* 45 */       if ((result == null) || (result.size() == 0)) {
/* 46 */         return;
/*    */       }
/*    */ 
/* 49 */       TaskManager taskManager = new TaskManager();

/* 50 */        for (Object itemsO : result) {

            Map items = (Map)itemsO;
/*    */
/* 52 */         Date lastGenerateDate = (Date)items.get("LastGenerateDate");
/* 53 */         if (lastGenerateDate != null) {
/* 55 */           Calendar createCal = Calendar.getInstance();
/* 56 */           createCal.setTime(lastGenerateDate);
/* 57 */           int createYear = createCal.get(1);
/* 58 */           if (createYear == year);
/*    */         }
/*    */         else {
/* 63 */           String name = (String)items.get("Name");
/* 64 */           int importantDateId =
/* 65 */             Util.str2Int(items.get("ImportantDateId"));
/* 66 */           int customerId = Util.str2Int(items.get("CustomerId"));
/* 67 */           int customerType = Util.str2Int(items.get("Type"));
/* 68 */           String importantDateType =
/* 69 */             (String)items
/* 69 */             .get("ImportantDateType");
/* 70 */           String permissionsId = (String)items.get("PermissionsId");
/* 71 */           int companyId = Util.str2Int(items.get("CompanyId"));
/*    */ 
/* 73 */           String taskTitle = importantDateType + "(" + year + "-" + month +
/* 74 */             "-" + day + ")";
/*    */ 
/* 76 */           String referenceUrl = null;
/* 77 */           if (customerType == 0)
/* 78 */             referenceUrl = "/company/";
/*    */           else {
/* 80 */             referenceUrl = "/people/";
/*    */           }
/* 82 */           referenceUrl = referenceUrl + customerId;
/*    */ 
/* 84 */           Date dueDate = cal.getTime();
/*    */ 
/* 87 */           taskManager.add(taskTitle, dueDate, permissionsId, 0,
/* 88 */             1, referenceUrl, name, companyId, 
/* 89 */             customerId, customerType, "admin");
/*    */ 
/* 94 */           manager.updateLastGenerateDate(importantDateId);
/*    */         }
/*    */       }
/*    */     } catch (DBException e) {
/* 98 */       e.printStackTrace();
/*    */     } catch (SQLException se) {
/* 100 */       se.printStackTrace();
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.thread.ImportantDateThread
 * JD-Core Version:    0.6.1
 */